package com.edu.exam.enums.grading;

/**
 * 权限范围枚举
 */
public enum PermissionScope {
    GLOBAL("GLOBAL", "全局权限"),
    DEPARTMENT("DEPARTMENT", "部门权限"),
    CLASS("CLASS", "班级权限"),
    COURSE("COURSE", "课程权限"),
    STUDENT("STUDENT", "学生权限"),
    TEACHER("TEACHER", "教师权限"),
    ADMIN("ADMIN", "管理员权限"),
    SYSTEM("SYSTEM", "系统权限"),
    USER("USER", "用户权限"),
    ROLE("ROLE", "角色权限");

    private final String code;
    private final String description;

    PermissionScope(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PermissionScope fromCode(String code) {
        for (PermissionScope scope : values()) {
            if (scope.getCode().equals(code)) {
                return scope;
            }
        }
        throw new IllegalArgumentException("Unknown permission scope code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}